#pragma once
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

template <class T>
class Request
{
public:
	Request(){};
	virtual ~Request(){};

public:
	virtual bool response() = 0;

public:
	/*
	 * 输出
	 */
	std::stringstream		out;
	std::stringstream		err;
	
public:
	/*
	 * 入口函数
	 */
	virtual void handler()
	{
		if(false == response())
		{
			if(0 == err.str().size())
			{
				err << "<html><body>"
					<< "<h1>internal error</h1>"
					<< "</body></html>";
			}

			out.clear();
			out << err.str().c_str();
		}
		
		printf("Content-type: text/html\r\n"
				"\r\n"
				"%s",
				out.str().c_str());
	
	}
};

